package biz;

import java.util.List;

import dao.CategoryDao;
import entity.Category;
import util.BaseBiz;

public class CategoryBiz extends BaseBiz implements CategoryDao{

	public List<Category> findparents() {
		
		return (List<Category>) excute(getMethod());
	}

	public Integer insertcate(Category cate) {
		
		return  (Integer) excute(getMethod(),cate);
	}

	public List<Category> findchildren(Integer cid) {
		
		return (List<Category>) excute(getMethod(), cid);
	}
	
	

	public Integer inserttwocate(Category cate) {
		
		return (Integer) excute(getMethod(),cate);
	}
	
	public List<Category> findparentsAndChildren()
	{
		List<Category> parent = findparents();
		int i =0;
		for(Category cate :parent)
		{
			List<Category> children=findchildren(cate.getCid());
			if(!children.isEmpty())
			{
				parent.get(i).setChildren(children);
			}
			i+=1;
		}
		return parent;
	}

	public Category findCategoryById(Integer cid) {
		
		return (Category) excute(getMethod(),cid);
	}

	public Integer updatefathercate(Category cate) {
		
		return (Integer) excute(getMethod(),cate);
	}

	public Integer deletechildrencate(Integer pid) {
		
		return (Integer) excute(getMethod(),pid);
	}

	public Integer deletefathercatebyid(Integer cid) {
		
		return (Integer) excute(getMethod(),cid);
	}

	public Category findchildcatebyid(Integer cid) {
		
		return (Category) excute(getMethod(),cid);
	}

	public Integer updatechildcate(Category cate) {
		
		return (Integer) excute(getMethod(),cate);
	}

	public Integer deletechildcateById(Integer cid) {
		
		return (Integer) excute(getMethod(),cid);
	}

	

}
